<%@include file="loginHeader.jsp" %>

<div id="content">
	<div id="login" align="center">
		<h1> Welcome to Lab Assistant. Please log in. </h1>
		
		<%
			int MAX_COUNT = 3;
			String count = request.getParameter("count");
			int loginCount = 0;
			try {
				loginCount = Integer.parseInt(count);
				if (loginCount == -1) {
					//This is our cue that the account has been suspended.
					out.println("<p style=\"color:red;\">");
					out.println("This account has been suspended. Please contact your administrator " +
								"for further instruction.");
					out.println("</p>");
				}
				else if (loginCount < MAX_COUNT) {
					out.println("<p style=\"color:red;\">");
					out.println("Wrong Username and Password combination. Please try again. " +
								"You have " + (MAX_COUNT - loginCount) + " login attempts remaining.");
					out.println("</p>");
				}
				else {
					out.println("<p style=\"color:red;\">");
					out.println("Wrong Username and Password combination. This account has been " + 
								"suspended. Please contact your administrator for further instruction.");
					out.println("</p>");
				}
			}
			catch (NumberFormatException e) {
				//This is the first time that the page is accessed. Destroy any cookie.
			}
			
		%>
		
		<form name="auth" action="Authenticate" method="post" >
			<%
				out.println("<input type=\"hidden\" name=\"count\" value="+ loginCount +">");
			%>
			
			  <table>
			    <tr>
			      <td align=right>
			        User name:
			        </td>
			      <td align=left>
			        <input type="text" name="name" value="" size=25 maxlength=15>
			        </td>
			      </tr>
			    <tr>
			      <td align=right>
			        Password:
		          </td>
			      <td align=left>
			        <input type="password" name="password" value="" size=25 maxlength=30>
		          </td>
		         </tr>
			    <tr>
			      <td colspan=2 align=center>
			        <input type="submit" name="action" value="Login">
		           </td>
		         </tr>
			</table>
		</form> 
	</div>
</div> 

<%@include file="footer.jsp" %>